<template>
	<view>
		<view class="container">
			<view>登录纯净小说</view>
			<input class="input" type="text" v-model="user.userName" placeholder="手机号/邮箱" placeholder-class="placeholder" />
			<input class="input" type="text" v-model="user.password" placeholder="密码" placeholder-class="placeholder" />
			<button type="default" @click="login()">登录</button>
			<view @click="gotoRegister">注册</view>
		</view>
		<page-tabpars></page-tabpars>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				user:{
					userName:'',
					password:''
				}
			}
		},
		methods: {
			gotoRegister(){
				uni.navigateTo({
					url: '/pages/member/register/register'
				});
			},
			gotoPerson(){
					this.$store.commit('SET_ACTIVE','person');
				uni.switchTab({
					url: '/pages/tabBar/person/person'
				});
			},
			login(){
				this.$myRequist({
					url: "/user/login",
					method:"post",
					data:this.user
				}).then(res => {
					console.log(res.data);
					console.log(res.data.data);
					this.$store.commit('login',res.data.data.token)
					this.gotoPerson();
				});
			}
		}
	}
</script>

<style lang="scss" scoped>
.container>*{
	color: white;
	text-align: center;
	margin: 22px;
}
.placeholder{
	color: $uni-text-color-grey;
}
</style>
